package avicit.bdp.dms.tdm.utils;

import avicit.platform6.api.sysuser.dto.SysOrg;
import avicit.platform6.core.context.ThreadContextHelper;
import avicit.platform6.core.domain.BeanDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

@Component
public class TdmLogContent {

  @Autowired private SysOrgUtils sysOrgUtils;

  /**
   * 增加获取内容
   *
   * @param dto
   * @param id
   * @param type
   * @return
   */
  public String addContent(BeanDTO dto, String id, String type) {
    String result = "";
    if (dto != null) {
      SysOrg org = sysOrgUtils.getOrgByUserId(ThreadContextHelper.getUserId());
      if (org != null) {
        String orgName = org.getOrgName();
        result =
            "[新增]【"
                + orgName
                + "】,用户名称为："
                + "【"
                + ThreadContextHelper.getUserName()
                + "】"
                + type
                + "数据,id:【"
                + id
                + "】";
      }
    }
    return result;
  }

  /**
   * 修改获取内容
   *
   * @param dto
   * @param id
   * @param type
   */
  public String updateContent(BeanDTO dto, String id, String type) {
    String result = "";
    if (dto != null) {
      SysOrg org = sysOrgUtils.getOrgByUserId(ThreadContextHelper.getUserId());
      if (org != null) {
        String orgName = org.getOrgName();
        result =
            "[修改]【"
                + orgName
                + "】,用户名称为："
                + "【"
                + ThreadContextHelper.getUserName()
                + "】"
                + type
                + "数据,id:【"
                + id
                + "】";
      }
    }
    return result;
  }

  /**
   * 删除获取内容
   *
   * @param dto
   * @param id
   * @param type
   * @return
   */
  public String deleteContent(BeanDTO dto, String id, String type) {
    String result = "";
    if (dto != null) {
      SysOrg org = sysOrgUtils.getOrgByUserId(ThreadContextHelper.getUserId());
      if (org != null) {
        String orgName = org.getOrgName();
        result =
            "[删除]【"
                + orgName
                + "】,用户名称为："
                + "【"
                + ThreadContextHelper.getUserName()
                + "】"
                + type
                + "数据,id:【"
                + id
                + "】";
      }
    }
    return result;
  }
}
